Skip to content

Conversation

@MariusStorhaug
Copy link
Member

@MariusStorhaug MariusStorhaug commented Oct 1, 2025

Overview

This release introduces automated test environment management through BeforeAll.ps1 and AfterAll.ps1 scripts, enabling comprehensive setup and teardown capabilities for module tests running in GitHub Actions. This enhancement solves the challenge of managing complex test environments (databases, infrastructure, external services) across parallel test matrices while ensuring proper cleanup regardless of test outcomes.

🎯 Main Feature: Test Lifecycle Management

The Problem

Previously, setting up test infrastructure required:

  • Rate-limiting issue when creating GitHub Repositories for the GitHub PowerShell module, where the setup and teardown happens in the individual test files via BeforeAll and AfterAll blocks.

The Solution

Dedicated setup and teardown jobs with automatic script execution:

  • BeforeAll: Runs once before all test matrix jobs begin.
  • AfterAll: Runs once after all test matrix jobs complete.

Configuration

No configuration needed! Simply add scripts to your test directory.
The workflow automatically detects and executes these scripts when present.

your-module/
├── tests/
│   ├── BeforeAll.ps1      ← Setup script (optional)
│   ├── AfterAll.ps1       ← Teardown script (optional)
│   └── Module.Tests.ps1   ← The tests that require external setup
│

Additional: Specification-Driven Development Framework

This release also includes an implementation of spec-kit principles, adding a structured workflow for feature development from specification through implementation.

What's Included

  • Prompt templates (.github/prompts/) for /specify, /clarify, /plan, /tasks, /analyze, /implement commands
  • Project constitution (.specify/memory/constitution.md) defining architectural principles:

Additional Workflow Improvements

Linter Configuration Updates

  • Added VALIDATE_BIOME_FORMAT: false for Biome formatter
  • Added VALIDATE_GITHUB_ACTIONS_ZIZMOR: false for workflow security scanning
  • Added VALIDATE_JSCPD: false for copy-paste detection
  • Consistent linting configuration across Build-Docs and Linter workflows

Test Workflow Enhancements

  • Environment variables properly scoped at workflow level
  • Clearer parameter naming (OSName vs OS)
  • Improved test execution coordination

Documentation

  • Comprehensive setup/teardown guide in README.md
  • Inline documentation in all prompt templates and scripts
  • Usage examples for common test scenarios

Copilot AI and others added 21 commits July 4, 2025 13:32
Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
…tation

Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
…tecture

Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
…e detection logic

Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
…g workflows

Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
- Implemented `setup-plan.ps1` to create an implementation plan for features, including JSON output option and template handling.
- Developed `update-agent-context.ps1` to update agent context files based on `plan.md`, supporting multiple agent types and ensuring environment validation.
- Created templates for agent files and implementation plans to standardize documentation and facilitate easier updates.
- Introduced a comprehensive feature specification template to guide feature development and ensure clarity in requirements.
- Added a task template to streamline task generation for feature implementation, ensuring proper sequencing and dependencies.
- Introduced quickstart.md for validating setup-test composite action functionality.
- Included prerequisites, integration steps, validation checklist, and test scenarios.
- Documented expected outcomes and debug commands for ease of use.

---

feat: Document research findings for local GitHub composite action

- Created research.md consolidating decisions on composite action structure, error handling, and integration patterns.
- Outlined rationale for using a single action with mode parameter for BeforeAll and AfterAll scripts.
- Provided implementation guidance and technical decisions summary.

---

feat: Define tasks for implementing local GitHub composite action

- Established tasks.md outlining execution flow, task dependencies, and phases for implementation.
- Specified tasks for setup, testing, core implementation, integration, and polish.
- Included validation checklist to ensure all requirements are met before execution.
…intended use and provide examples for managing external test resources
@MariusStorhaug MariusStorhaug requested a review from a team as a code owner October 1, 2025 16:02
Copilot AI review requested due to automatic review settings October 1, 2025 16:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request introduces test setup and teardown capability for PowerShell modules through a comprehensive enhancement to the Process-PSModule framework. The main purpose is to enable test infrastructure setup and cleanup scripts that can run before and after test matrix jobs across all platforms.

Key changes include:

  • Addition of BeforeAll.ps1 and AfterAll.ps1 test scripts that execute automatically during test workflows
  • Enhanced Test-ModuleLocal.yml workflow with dedicated setup and teardown jobs
  • Complete feature specification and implementation plan with contracts and documentation
  • Updated README with comprehensive documentation of the new test setup capabilities

Reviewed Changes

Copilot reviewed 37 out of 37 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/srcWithManifestTestRepo/tests/MyTests/BeforeAll.ps1 Example BeforeAll setup script for MyTests directory
tests/srcWithManifestTestRepo/tests/MyTests/AfterAll.ps1 Example AfterAll teardown script for MyTests directory
tests/srcWithManifestTestRepo/tests/Environments/BeforeAll.ps1 Example BeforeAll setup script for Environments directory
tests/srcWithManifestTestRepo/tests/Environments/AfterAll.ps1 Example AfterAll teardown script for Environments directory
tests/srcTestRepo/tests/BeforeAll.ps1 Main BeforeAll setup script with comprehensive setup tasks
tests/srcTestRepo/tests/AfterAll.ps1 Main AfterAll teardown script with comprehensive cleanup tasks
.github/workflows/Test-ModuleLocal.yml Enhanced workflow with BeforeAll-ModuleLocal and AfterAll-ModuleLocal jobs
.github/workflows/workflow.yml Updated to pass ModuleTestSuites instead of matrix parameters
.github/workflows/CI.yml Updated to pass ModuleTestSuites instead of matrix parameters
README.md Added comprehensive documentation for setup and teardown scripts
specs/001-building-on-this/* Complete feature specification and implementation artifacts

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copilot AI review requested due to automatic review settings October 1, 2025 17:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 35 out of 35 changed files in this pull request and generated no new comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copilot AI review requested due to automatic review settings October 1, 2025 20:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 37 out of 37 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

tests/srcWithManifestTestRepo/tests/BeforeAll.ps1:1

  • The final message says 'AFTERALL SETUP SCRIPT' but should say 'BEFOREALL SETUP SCRIPT' to match the script's purpose.
Write-Host "=== BEFOREALL SETUP SCRIPT (Environments) EXECUTING ==="

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

MariusStorhaug and others added 2 commits October 1, 2025 22:47
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings October 1, 2025 21:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 39 out of 39 changed files in this pull request and generated 3 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copilot AI review requested due to automatic review settings October 1, 2025 21:25
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 39 out of 39 changed files in this pull request and generated 4 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copilot AI review requested due to automatic review settings October 1, 2025 21:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 39 out of 39 changed files in this pull request and generated 4 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@MariusStorhaug MariusStorhaug changed the title Add test setup and teardown capability 🚀[Feature]: Add setup and teardown capability for tests Oct 1, 2025
…ub composite action for BeforeAll/AfterAll test scripts as part of project restructuring. This includes the deletion of research.md, spec.md, and tasks.md files, consolidating the documentation and streamlining the development process.
…eAll and AfterAll scripts for cleaner execution flow
Copilot AI review requested due to automatic review settings October 1, 2025 21:45
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 30 out of 30 changed files in this pull request and generated no new comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@MariusStorhaug MariusStorhaug changed the title 🚀[Feature]: Add setup and teardown capability for tests 🚀[Feature]: Test Setup & Teardown Support for GitHub Actions Workflows Oct 1, 2025
@MariusStorhaug MariusStorhaug self-assigned this Oct 1, 2025
@MariusStorhaug MariusStorhaug merged commit 7e38e21 into main Oct 1, 2025
110 of 112 checks passed
@MariusStorhaug MariusStorhaug deleted the 001-building-on-this branch October 1, 2025 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🚀[Feature]: Add support for running setup and teardown scripts during tests

2 participants